package com.itheima.controller;


import com.itheima.controller.exception.BusinessException;
import com.itheima.controller.exception.SystemException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class ProjectExceptionAdvice {


     @ExceptionHandler(SystemException.class)
     public Result doSystemException(SystemException sy){


          return new Result(Code.SYSTEM_ERR,null,sy.getMessage());

     }
     @ExceptionHandler(BusinessException.class)
    public Result doBusinessException(BusinessException be){
         return new Result(Code.BUSINESS_ERR,null,be.getMessage());
    }
    @ExceptionHandler(Exception.class)
    public Result doSException(Exception e){
        return new Result(Code.SYSTEM_UNKNOW_ERR,null,"系统繁忙，请稍后再试！");
    }
}
